﻿using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using Microsoft.Xna.Framework;
using Microsoft.Xna.Framework.Graphics;
using Microsoft.Xna.Framework.Content;

namespace Jemgine.Particles
{
    public class ParticleEffect
    {
        public List<Emitter> Emitters = new List<Emitter>();

        public void Initialize(GraphicsDevice Device, ContentManager Content)
        {
            foreach (var Emitter in Emitters)
                Emitter.Initialize(Device, Content);            
        }

        public void Emit(Vector2 _position, float _angle)
        {
            foreach (var Emitter in Emitters)
                Emitter.Emit(_position, _angle);
        }

        public void Update(float ElapsedSeconds)
        {
            foreach (var Emitter in Emitters)
                Emitter.Update(ElapsedSeconds);
        }

        public int TotalActiveParticles
        {
            get
            {
                int TAP = 0;
                foreach (var Emitter in Emitters)
                    TAP += Emitter._particleCount;
                return TAP;
            }
        }

        public int TotalPotentialParticles
        {
            get
            {
                int TPP = 0;
                foreach (var Emitter in Emitters)
                    TPP += Emitter.MaxParticles;
                return TPP;
            }
        }

        public void ReleaseBuffers()
        {
            foreach (var Emitter in Emitters) Emitter.ReleaseBuffers();
        }
    }
}
